<template>
	<view class="container">
		<view class="banner">
			<image :src="companyInfo.compImg?companyInfo.compImg:totalImg" mode="widthFix" style="min-height: 336rpx" />
		</view>
		<view class="tc">
			<view class="head">
				<image class="avatrar" :src="companyInfo.logo?companyInfo.logo : '/static/image/wutouxiang.png'" />
				<view class="attr">
					<view class="item">
						<view class="text">访客</view>
						<view class="num">
							{{visitCount}}
						</view>
					</view>
					<view class="item">
						<view class="text">关注</view>
						<view class="num"> {{attentionCount}}</view>
					</view>
					<view class="item">
						<view class="text">粉丝</view>
						<view class="num">{{attentionMineCount}}</view>
					</view>
				</view>
			</view>
			<view class="name">{{companyInfo.company}}</view>
			<view class="info">
				<image class="img" src="/static/image/zhengque.png" mode="widthFix" />
				服务地区：
				<view v-for="(address,index) in companyInfo.showAddress" v-show="index < 5">{{address}}</view>
			</view>
			<view class="info">
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/v.png" mode="widthFix" />
				企业性质：{{companyInfo.companyNature}}
			</view>
			<view class="text" style="margin-top: 24rpx;">{{companyInfo.personSign}}</view>

			<view v-if="exhibition.length>0" v-for="(item, index) in exhibition"
				style="display: flex;background: rgb(255, 243, 243);margin: 20rpx 16rpx -5px 6rpx;    border-radius: 20rpx 0px 20rpx 20rpx;">
				<view>
					<image style="width:76rpx;height:40rpx; margin-left: 14rpx;margin-top: 10rpx;" src="https://m.nocexpo.com/statics/js/modules/h5/img/yicanzhan.png" alt="" />
				</view>
				<view class="content">
					<view id="text" :class="exhibition.length>1?'text':''" style="display: flex;line-height: 30px;margin-left: 20px;">
						<view >{{item.exhibitionShortName}}展位号 :
							{{item.exhibitionHall}}{{item.boothNumber}}&nbsp&nbsp&nbsp&nbsp&nbsp
						</view>
            <view style="width: 124rpx;height: 24px;line-height: 24px;text-align: center;color: #ffffff;background: linear-gradient(360deg, #00aaa6 0%, #54d6d2 100%);border-radius: 8rpx; margin-top: 3px;" @click="topregFormUrl(item.exhibitionEntity.pregFormUrl)">领取门票</view>
					</view>
				</view>
			</view>

		</view>
		<view class="tabs" :class="fixedTab?'fixedTab':''">
			<view class="item " @click="tabIndex=1" :class="tabIndex == 1 ? 'active' : ''">
				产品({{products.length}})
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/banhu.png" mode="widthFix" />
			</view>
			<view class="item" @click="tabIndex=2" :class="tabIndex == 2 ? 'active' : ''">
				样册({{sampleBookList.length}})
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/banhu.png" mode="widthFix" />
			</view>

			<view class="item" @click="tabIndex=3" :class="tabIndex == 3 ? 'active' : ''">
				简介
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/banhu.png" mode="widthFix" />
			</view>

			<view class="item" @click="tabIndex=4" :class="tabIndex == 4 ? 'active' : ''">
				视频({{videoSearch.totalCount}})
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/banhu.png" mode="widthFix" />
			</view>

			<view class="item" @click="tabIndex=5" :class="tabIndex == 5 ? 'active' : ''">
				动态({{newsSearch.totalCount}})
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/banhu.png" mode="widthFix" />
			</view>
		</view>
		<view class="scroll-view" scroll-y>
			<view v-if="tabIndex == 1" class="c">
				<view class="product-data-list" v-if="products.length > 0">
					<navigator v-for="item in products" :key="item.id" class="item" @click="toProductDetail(item.id)"
						hover-class="none">

						<view class="tit-a" v-if="item.exhibitionList != null" v-for="(ee,index) in item.exhibitionList"
							style="width: 50%;position: absolute;top: 0;right: 0;color: #fff"
							:style="{background: getProductFontBackgroundColor(item)}">
							{{item.exhibitionList[0].exhibitionShortName}}
						</view>
						<image class="img" :src="item.banarImg" mode="widthFix" />
						<view class="title">{{item.tradeName}}</view>

						<view class="type-price">
							<view class="price">
								<text>￥</text>
								{{item.price == 0 ? '询价': item.price}}
							</view>
							<view class="type">{{item.brandName}}</view>
						</view>
					</navigator>
				</view>
			</view>
			<view v-if="tabIndex == 2" class="c">
				<view class="product-data-list yang" v-if="sampleBookList.length > 0">
					<view v-for="item in sampleBookList" :key="item.id" class="item" hover-class="none">
						<image class="img" :src="item.imgUrl" mode="widthFix" @click="toPDF(item)"/>
						<view class="title">{{item.bookName}}</view>
						<view class="type-name">品牌：{{item.brandName}}</view>
					</view>
				</view>
			</view>
			<view v-if="tabIndex == 3" class="c companyDetail">
				<rich-text v-html="companyInfo.details ? companyInfo.details:'暂无'"></rich-text>
			</view>
			<view v-if="tabIndex == 4" class="c">
				<view class="video-data">
					<!-- <custom-waterfalls-flow :columnSpace="1.5" :value="videoList"  v-show="videoList.length > 0"> -->
					<view class="item" v-for="(item, index) in videoList" :key="index" slot="slot{{index}}"
						@click="toVideoDetail(item.id)">
						<image class="img"
							:src="item.coverImg?item.coverImg:(item.videoUrl+'?x-oss-process=video/snapshot,t_7000,f_jpg,m_fast')" />

						<view class="title">{{item.videoTitle}}</view>
						<view class="user-collent ">
							<view class="user">
								<image class="avatar"
									:src="item.coverImg?item.coverImg:(item.videoUrl+'?x-oss-process=video/snapshot,t_7000,f_jpg,m_fast')" />
								<text>{{item.author.userName}}</text>


							</view>
							<view class="num">{{item.browseCount}}播放</view>
						</view>

						<!-- <image v-if="index % 2 == 0" class="play" src="/static/image/video.png" mode="widthFix" /> -->
						<!-- <view v-else class="zhibo">
								<image src="/static/image/video.png" mode="widthFix" />
								直播回访
							</view> -->
					</view>
					<!-- </custom-waterfalls-flow> -->
				</view>
			</view>
			<view v-if="tabIndex == 5" class="c">
				<view class="video-data">
					<!-- <custom-waterfalls-flow v-if="newsList.length > 0"> -->
					<view class="item" v-for="(item, index) in newsList" :key="index" slot="slot{{index}}"
						@click="toNewsDetail(item.id)">
						<image class="img" :src="item.pictureUrl" />
							<view class="title">{{item.title}}</view>
						<view class="user-collent ">
							<view class="user">
								<image class="avatar"
									:src="item.author.protrait?item.author.portrait : 'https://img0.baidu.com/it/u=3075622271,3356712518&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666'" />

								<text>{{item.author.userName}}</text>
							</view>

							<view class="num">{{item.browseCount}}浏览</view>
						</view>
						<!-- <image v-if="index % 2 == 0" class="play" src="/static/image/video.png" mode="widthFix" /> -->
						<!-- <view v-else class="zhibo">
								<image src="/static/image/video.png" mode="widthFix" />
								直播回访
							</view> -->
					</view>
					<!-- </custom-waterfalls-flow> -->
				</view>
			</view>
		</view>
		<view class="fixed-oper">
			<view class="icons">
				<view class="item" @click="toIndex()">
					<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/zhanting.png" mode="widthFix" />
					<view class="name">首页</view>
				</view>

				<view class="item">
					<image class="img" @click="sendMsg()" src="https://m.nocexpo.com/statics/js/modules/h5/img/comment.png" mode="widthFix" />
					<view class="name">私聊</view>
				</view>
			</view>
			<view class="btns">
				<view class="btn" @click="toCall()">电话联系</view>
				<view v-if="currentUser.id != companyInfo.id" class="btn btn-yes" @click="shoucang()"
					:class="[ shoucangFlag?'on':'off' ]">
					<!-- <uni-icons class="icon" color="#ffffff" type="plusempty" size="12"></uni-icons> -->
					{{shoucangFlag ? '已关注' : '关注'}}
				</view>
				<view v-else class="btn btn-yes" @click="toEditInfomation()">编辑</view>
			</view>
		</view>
		<uni-popup ref="contact" type="center">
			<view class="contact-module">
				<view class="item" v-for="(item,index) in serviceTelList" :key="item.id">
					<view class="left">
						<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/ren.png" mode="widthFix" />
						{{item.remark}}
					</view>
          <a :id="'callGP'+index" style="display: none" :href="item.serviceTel?'tel:'+item.serviceTel:'javascript:void(0)'"></a>
        <image @click="callPhone(6, currentUser.id, companyInfo.id, 3, item.serviceTel,index, currentUser.type, currentUser.state)" class="right" src="https://m.nocexpo.com/statics/js/modules/h5/img/icon_phone.png" mode="widthFix" />
		</view>
				<view class="text">联系我时，请说明是“金诺云展”推荐的，谢谢</view>
			</view>
			<view class="contact-close" @click="$refs.contact.close()">
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/closs.png" mode="widthFix" />
			</view>
		</uni-popup>
		<!--海报弹窗-->
		<suspension types="group,se" v-if="codeImg"
                :exhTitle="title"
                :exhSubTitle="subTitle"
                :exhHeaderImg="headerImg"
                :exhContent="content"
			          :exhBackgroundImg="backgroundImg"
                :exhCompanyImg="companyImg"
                :exhCodeImg="codeImg"
		 ></suspension>

	</view>
</template>

<script>
	import roomdetailApi from '@/api/showroom.js';
	import productDetailApi from '@/api/productdetail.js';
	import commonApi from '@/utils/commonMethod.js';
	export default {
		data() {
			return {
				// nocCompanyDataVo: {
				// 	visitCount: 731,
				// 	collectCount: null,
				// 	dianzanCount: 4,
				// 	dianzanFlag: false,
				// 	shoucangFlag: false,
				// 	contactUserCount: null,
				// 	attentionCount:1,
				// 	attentionMineCount:1,
				// },
				tabIndex: 1,
				fixedTab: false,
				videoShow: false, //直播预告弹窗
				scroll: '',
				Topscroll: false,
				id: '',
				currentUserId: '',
				isShowFriend: false,
				companyInfo: {}, //企业信息
				products: [], //产品列表
				visitors: [], //访问人员列表
				visitNames: '', //访问人员姓名(逗号分隔)
				visitCount: 0, //访问总数量
				dianzanFlag: false, //需要从后台获取当前登录人是否点过赞  点赞不可取消
				shoucangFlag: false, //需要从后台获取当前登录人是否已收藏  收藏可取消
				dianzanCount: 0, //点赞总数量
				sw_flag: 0,
				totalImg: '',
				middleImg: '',
				currentUser: {},
				serviceTelList: [],
				videoList: [],
				videoList1: [],
				videoList2: [],
				likeList: [],
				isFixed: false,
				activeIndex: 0,
				videoLine: {
					loading: false, //正在加载
					noMore: false, //没有更多数据
					noData: false, //没有数据
				},
				likeLine: {
					loading: false, //正在加载
					noMore: false, //没有更多数据
					noData: false, //没有数据
				},
				newsLine: {
					loading: false, //正在加载
					noMore: false, //没有更多数据
					noData: false, //没有数据
				},
				videoSearch: {
					page: 1,
					limit: 10,
					search: '',
					lastpage: 0,
					totalPage: '',
					userId: '',
					totalCount: 0
				},
				likeSearch: {
					page: 1,
					limit: 10,
					search: '',
					lastpage: 0,
					totalPage: '',
					userId: '',
					totalCount: 0
				},
				newsSearch: {
					page: 1,
					limit: 10,
					search: '',
					lastpage: 0,
					totalPage: '',
					userId: '',
					totalCount: 0
				},
				likeMineCount: '', //被点赞量
				attentionCount: '', //获取关注数量
				attentionMineCount: '', //获取粉丝数量
				newsList: [], //资讯数据
				newsList1: [], //资讯数据
				newsList2: [], //资讯数据
				sampleBookList: [], //样册
				modeOne: 0,
				modeTwo: 0,
				modeThree: 0,
				modeFour: 0,
				modeFive: 0,
				exhibitionsName: '', //展会名
				exhibition: [], //展会信息
				ifRoll: true, //公告是否滚动
				ifOneself: false, //是否供应商本人
				classifyAddress: [], //分类后的服务地区
				showCompany: true,
				myLiveroom: {
					fengmianImgUrl: '',
					status: ''
				},

				share_desc:'金诺云展-机械加工行业采购对接平台，欢迎来我司展厅参观',
				share_url:'',

				startTime:'', //进入页面时间
				endTime:'',//离开页面时间
				currentUrl:'',//当前页面全路径

				title:'',
				subTitle: '',
				headerImg:'',
				content: '',
				compInfo: {},
				companyImg:'',
				codeImg:'',
				backgroundImg: 'https://m.nocexpo.com/statics/js/modules/h5/img/temp/shareback1.png'
			};
		},
		async onLoad(options) {
			this.getMyliveRoom(options.userId);
			this.id = parseInt(options.userId);
			this.videoSearch.userId = options.userId;
			this.likeSearch.userId = options.userId;
			this.newsSearch.userId = options.userId;

			this.companyInfo.exhibitionId = 0;
			//预登记系统自动登录功能
			// await preRegistration()
			//获取当前用户
			this.getCurrentUser();
			//判断是否供应商本人
			if (this.id == this.currentUser.id) {
				this.ifOneself = true
			}

			this.query()
			this.getExhibitionByUser()
			this.getExhibitionInfo()
			//不是页面回退



			//查询当前企业发布的视频
			await this.queryVideo()
			//查询当前企业的喜欢
			await this.queryLike()
			//查询当前企业动态
			await this.getNewsList();

			await this.createImage();
			await this.getCompInfo(options.userId);

			//从展厅进入其他展厅/主页出现session覆盖，页面回退session取值数据出错，故携带标志，有则刷新页面


			// this.doSortVideoList(0, this.videoList);

			//获取被点赞
			await commonApi.getCollectMineByType(this.id, [4]).then(res => {
				this.likeMineCount = res.data.countAndList.count
			});

			//获取我的关注
			await commonApi.getCollectionCountByTypeAxios(3, this.id).then(res => {
				this.attentionCount = res.data.page.totalCount

			});


			//获取粉丝数
			await commonApi.getCollectMineByType(this.id, [3]).then(res => {
				this.attentionMineCount = res.data.countAndList.count

			});
			commonApi.getPageShareConfig().then(res =>{
				  res.data.list.forEach((value, index, array) => {
					if (value.pageParam.includes("exhibition")) {
						if (value.shareDescConfig != null && value.shareDescConfig != '') {
							this.share_desc = value.shareDescConfig
						}
					}
				})
			})
      const pages = getCurrentPages()
      const currentPage =pages[pages.length - 1]
      this.share_url = currentPage.$page.fullPath

		},
		onShow(){

			setTimeout(()=> {

				if (getApp().globalData.onShow) {
					getApp().globalData.onShow = 0;
					console.log("demo前后台切换之切到前台")
				}
				else {
					console.log("demo页面被切换显示")
					this.startTime = +new Date();
				}

			}, 100);
		},
		onHide(){
			setTimeout(() => {
				var that = this
				if (getApp().globalData.onHide) {
					getApp().globalData.onHide = 0;
					console.log("还在当前页面活动")
				}
				else {
					that.endTime = +new Date();
					console.log("demo页面停留时间：" + (that.endTime - that.startTime))
					var stayTime = Math.round((that.endTime - that.startTime)/1000);
				   //这里获取到页面停留时间stayTime，然后了可以上报了
				   this.saveFootPrint(stayTime);
				}
			}, 100)
		},
		onUnload(){
			this.removePosterImg()
			setTimeout(() => {
				var that = this
				if (getApp().globalData.onHide) {
					getApp().globalData.onHide = 0;
					console.log("还在当前页面活动")
				}
				else {
					that.endTime = +new Date();
					console.log("demo页面停留时间：" + (that.endTime - that.startTime))
					var stayTime = Math.round((that.endTime - that.startTime)/1000);
				   //这里获取到页面停留时间stayTime，然后了可以上报了
				   this.saveFootPrint(stayTime);
				}
			}, 100)
		},
		async amounted() {
			await commonApi.recordBrowse(3,this.currentUser.id,this.id,3)
		},
		onShareAppMessage: function () {//分享
			return {
				title: this.companyInfo.company + '的线上展厅-金诺云展',
        path: this.share_url + "&sourceUserId=" + uni.getStorageSync("userId"),
				desc: this.share_desc,
				imageUrl: this.companyInfo.logo,
				success: function (res) {
					console.info(res + '成功');
					wx.showToast({
						title: '分享成功',
					})
					// 转发成功
				},
				fail: function (res) {
					console.log(res + '失败');
					// 转发失败
				},

			}
		 },
		/*分享朋友圈 */
		onShareTimeline: function() {
			return {
				title: this.companyInfo.company + '的线上展厅-金诺云展',
        query: 'userId=' + this.id + "&sourceUserId=" + uni.getStorageSync("userId"),
				imageUrl: this.companyInfo.logo,
			}
		},
		methods: {
			saveFootPrint(stayTime){
				commonApi.saveFootPrint(this.currentUser.id,this.startTime,stayTime,this.share_url,"商品展厅")

			},
			callPhone(type, userId, businessId, businessType, phone, phoneIndex, userType, userState){
						commonApi.callPhone(type, userId, businessId, businessType,phone, phoneIndex, userType, userState)
					},
			async getCurrentUser() {
				commonApi.currentUserAxios().then(res => {
					this.currentUser = res.data.session_user_h5;
				});
			},
			//关闭直播预告弹窗
			videoClose() {
				this.videoShow = false;
			},

			// 获取直播间
			getMyliveRoom(userId) {
				roomdetailApi.getMyliveRoom(userId).then(res => {
					this.myLiveroom = res.data.myLiveroom;
				});
			},


			query() {
				this.sw_flag = 0;
				roomdetailApi.query(this.id).then(res => {
					res.data.vo.nocUserEntity.details = decodeURIComponent(res.data.vo.nocUserEntity.details)
					res.data.vo.nocUserEntity.details = res.data.vo.nocUserEntity.details.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
					this.companyInfo = res.data.vo.nocUserEntity
					//处理服务地区
					let userAddress = this.companyInfo.serviceArea;
					if (null != userAddress) {
						//展厅展示的服务地区
						let showAddress = [];
						//分隔后的服务地区
						let splitAddress = [];
						//省份
						let province = [];
						let address = userAddress.split(",");
						for (let i = 0; i < address.length; i++) {
							let split = address[i].split("、");
							splitAddress.push(split);
							//获取地区的最后一级
							for (let j = split.length - 1; j >= 0; j--) {
								if (split[j] != "") {
									showAddress.push(split[j])
									break;
								}
							}
						}
						//添加到展商信息中
						this.companyInfo["showAddress"] = showAddress;
						//获取省份
						for (let i = 0; i < splitAddress.length; i++) {
							province.push(splitAddress[i][1])
						}
						//省份去重
						province = Array.from(new Set(province));
						//根据省份归类
						for (let x of province) {
							this.classifyAddress.push(this.findProvince(x, splitAddress));
						}
					}

					//查询当前企业相册
					this.getSampleBookList();
					this.getServiceTelList();
					this.totalImg = res.data.vo.totalImg;
					this.middleImg = res.data.vo.middleImg;

					this.products = res.data.vo.productEntities;
					this.products.forEach((value, index, array) => {
						value.price = commonApi.handlePrice(value.price)
					})

					this.visitors = res.data.vo.browsers
					this.visitNames = res.data.vo.visitNames
					this.visitCount = res.data.vo.nocCompanyDataVo.visitCount
					this.dianzanCount = res.data.vo.nocCompanyDataVo.dianzanCount
					this.dianzanFlag = res.data.vo.nocCompanyDataVo.dianzanFlag
					this.shoucangFlag = res.data.vo.nocCompanyDataVo.shoucangFlag
					this.currentUserId = res.data.vo.currentUserId

					this.sw_flag = 1;


				})
			},

			findProvince(province, showAddress) {
				let classifyAddress = [];
				for (let i = 0; i < showAddress.length; i++) {
					if (showAddress[i][1] == province) {
						classifyAddress.push(showAddress[i])
					}
				}
				return classifyAddress;
			},
			async shoucang() {

				//判断是否登录
				this.register = await commonApi.getUserLoginFlag();
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login',
					})
				}

				//判断注册手机和用户类型
				// const resul = await judgeIfPhone()
				// if (!resul) {
				// 	return
				// }
				// const result = toRegistered(vm.currentUser.type)
				// if (!result) {
				// 	return
				// }
				// let that = this
				this.shoucangFlag = !this.shoucangFlag
				commonApi.subscriptionOrNot(this.id, this.shoucangFlag).then(res => {

				});

			},


			//查询视频
			async queryVideo() {
				let videoList = [];
				commonApi.getVideoList(this.videoSearch).then(res => {
					videoList = res.data.page.list
					videoList.forEach(value => {
						if (value.videoDuration) {
							value.videoDuration = commonApi.formatDurantion(value)
						}
					})
					this.videoList = videoList;
					console.log(this.videoList);
					this.videoSearch.totalCount = res.data.page.totalCount;
					this.videoSearch.totalPage = res.data.page.totalPage;

				})
			},

			async toEditInfomation() {
			  uni.navigateTo({
			    url: '/pages/person/updatePersonInfo'
			  })
			},

			async queryLike() {
				this.getConnectVideo()
			},
			// 获取收藏的视频
			getConnectVideo() {
				roomdetailApi.getConnectVideo(this.likeSearch).then(res => {
					this.likeSearch.totalPage = res.data.page.totalPage;
					this.likeSearch.totalCount = res.data.page.totalCount;
					this.likeSearch.page = res.data.page.currPage;
					this.likeList = [...this.likeList, ...res.data.page.list];
					this.likeList.forEach((value, index, array) => {
						if (value.videoDuration) {
							commonApi.formatDurantion(value).then(res => {
								value.videoDuration = res.duration;
							})
						}
					})
				})
			},
			getServiceTelList() {
				roomdetailApi.getServiceTelList(this.companyInfo.id).then(res => {
					this.serviceTelList = res.data.serviceTelList;
				})
			},
			async toCall() {
				//判断是否登录
				this.register = await commonApi.getUserLoginFlag();
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login',
					})
				}

				this.$refs.contact.open();
			},
			showServiceTelList() {

				if (this.serviceTelList != null && this.serviceTelList.length > 0) {
					this.$refs.contact.open();
				} else {
					uni.showModal({
						title: "",
						content: "该企业暂未提供客服电话，可选择在线沟通.",
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});

				}
			},


			async getNewsList() {
				commonApi.getNews(this.newsSearch).then(res => {
					this.newsSearch.totalCount = res.data.page.totalCount;
					this.newsSearch.totalPage = res.data.page.totalPage;
					this.newsList = [...this.newsList, ...res.data.page.list];
					for (var i = 0; i < this.newsList.length; i++) {
						this.newsList[i].pictureUrl = this.newsList[i].pictureUrl.split(',')[0];
						if (this.newsList[i].author.userName != null) {
							if (this.newsList[i].author.userName.length > 6) {
								this.newsList[i].author.userName = this.newsList[i].author.userName.substring(
									0, 6);
							}
						}
					}
					console.log(this.newsList);
					// this.doSortNewsList(0, res.newsList);
				})
			},

			topregFormUrl(topregFormUrl){
				uni.navigateTo({
					url: '/components/webview/webview?url=' + encodeURIComponent(topregFormUrl.replace('-1', this.companyInfo.id)),
				})
			},

			//获取样册
			getSampleBookList() {
				roomdetailApi.getSampleBookList(this.companyInfo.id).then(res => {
					// if (window.performance && window.performance.navigation.type != 2) {
					this.sampleBookList = res.data.sampleBookList;
					// sessionStorage.setItem('sampleBookList', JSON.stringify(this.sampleBookList));
					// } else {
					// this.sampleBookList = JSON.parse(sessionStorage.getItem('sampleBookList'));
					// }
				})
			},


			//获取展商参加的展会
			getExhibitionByUser() {
				roomdetailApi.getExhibitionByUser(this.id).then(res => {
					this.exhibitionsName = res.data.list.map((obj) => {
						return obj.exhibitionName
					}).join("、");
					if (this.exhibitionsName.indexOf("、") == -1) {
						this.ifRoll = false;
					}
				});
			},
			// //获取展会信息
			getExhibitionInfo() {
				roomdetailApi.getExhibitionInfo(this.id).then(res => {
					this.exhibition = res.data.list
				})
			},

			createImage(){
        const path = `pages/product/showroom/showroom?userId=${this.id}`;
            roomdetailApi.getwxacode(path).then(result => {
          // 将Buffer流转换成base64格式
          let base64 = wx.arrayBufferToBase64(result.data);
          console.log('二维码图片', 'data:image/jpeg;base64,' + base64);
          // 将base64格式的图片保存到本地
          const imgPath = wx.env.USER_DATA_PATH + "/ercode" + new Date().getTime() + "" + ".png";
          const file = wx.getFileSystemManager();
          file.writeFileSync(imgPath, base64, "base64");
          this.codeImg = imgPath
        });

				/*uni.request({
					method: "GET",
					url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx41912017b5127580&secret=116440deeac5fe5e6610ceb27b6b612c`,
					success:(result) =>{
						let access_token = result.data.access_token
						// 获取到 access_token 后 获取二维码
						this.getQrCode(access_token)
					}
				})*/

			},

      /**
       * 获取二维码
       * @param token
       */
			getQrCode(token){
        /**
         * 通过uni.request 请求获取小程序码
         * 将小程序码转换成base64格式
         */
				/*uni.request({
					method: "POST",
					responseType: 'arraybuffer', // 注意一定要加 不然返回的Buffer流会乱码 导致无法转base64
          url: `https://api.weixin.qq.com/wxa/getwxacode?access_token=${token}`,
					data: {
            path: `pages/product/showroom/showroom?userId=${this.id}`, // 需要打开的页面路径
          },
					success: (result) => {
            // 将Buffer流转换成base64格式
            let base64 = wx.arrayBufferToBase64(result.data);
            //console.log('二维码图片', 'data:image/jpeg;base64,' + base64);
            // 将base64格式的图片保存到本地
            const imgPath = wx.env.USER_DATA_PATH + "/ercode" + new Date().getTime() + "" + ".png";
            const file = wx.getFileSystemManager();
            file.writeFileSync(imgPath, base64, "base64");
            this.codeImg = imgPath
          },
				})*/

			},


			removePosterImg (){
			  // 文件管理器
			  const fsm = wx.getFileSystemManager()
			  // 获取文件列表
			  fsm.readdir({
			    dirPath: wx.env.USER_DATA_PATH, // 当时写入的文件夹
			    success (res) {
			      res.files.forEach((el) => { // 遍历文件列表里的数据
			        // 删除存储的垃圾数据
			        if (el !== 'miniprogramLog') { // 过滤掉miniprogramLog
			          fsm.unlink({
			            filePath: `${wx.env.USER_DATA_PATH}/${el}`, // 文件夹也要加上，如果直接文件名会无法找到这个文件
			            fail (e) {
			              console.log('readdir文件删除失败：', e)
			            },
							  success(succ){
								  console.log('文件删除成功：',succ);
							  }
			          })
			        }
			      })
			    }
			  })
			},

			async getCompInfo(userId){
				productDetailApi.getCompInfo(userId + '').then(res =>{
						this.compInfo = res.data.vo
					this.title = this.compInfo.company
					this.companyImg = res.data.vo.logo
					this.headerImg = res.data.vo.compImg
				})
			},


			toIndex() {
				uni.switchTab({
					url: '/pages/tabBar/index/index'
				})
			},
			toVideoDetail(id) {
				uni.redirectTo({
					url: '/pages/product/vidoDetail/vidoDetail?id=' + id
				})
			},
			toNewsDetail(id) {
				uni.redirectTo({
					url: '/pages/product/imageText/imageText?id=' + id
				})
			},
			toProductDetail(id) {
				uni.redirectTo({
					url: '/pages/product/productDetail/productDetail?productId=' + id
				})
			},
			getProductFontBackgroundColor(product) {
				// if (product.hasOwnProperty("exhibitionList")){
				return product.exhibitionList[0].fontBackgroundColor
				// }
			},
			async sendMsg() {
				//判断是否登录
				this.register = await commonApi.getUserLoginFlag();
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login',
					})
				}
				uni.redirectTo({
					url: '/pages/news/chatDetail/chatDetail?toUserId=' + this.companyInfo.id +
						'&showroom=showroom'
				})
			},
      async toPDF(item) {

        uni.navigateTo({
          url:'/components/webview/webview?url=' + encodeURIComponent(item.bookUrl) + '&bookId=' + item.id
        });

        //判断是否登录
        /**
        this.register = await commonApi.getUserLoginFlag();
        if (this.register) {
          return
        } else {
          // 显示加载提示框（此处利用的消息提示框实现的加载提示框）
          uni.showToast({
            title: '加载中……',
            icon: 'loading',
            duration: 30000 // 当然这个时间可根据实用场景进行相关设置
          });
          uni.downloadFile({
            url: item.bookUrl,
            success: function (res) {
              let filePath = res.tempFilePath;   // 下载成功后返回的临时文件路径
              // 打开临时文件
              uni.openDocument({
                filePath: filePath,
                showMenu: true,
                success: function (res) {
                  // 随后在接口访问成功时关闭加载提示框
                  uni.hideToast();
                }
              });
            },
            fail: (err) => {
              // 处理下载失败的情况
            }
          });
        }
         **/
      },

		},
		onPageScroll(res) {
			if (res.scrollTop > 345) {
				this.fixedTab = true;
			} else {
				this.fixedTab = false;
			}
		},

	};
</script>

<style lang="scss">
	.container {
		height:auto;
		overflow-y:initial;

	}

	.banner {
		height: 336rpx;
		image {
			width: 100%;
			display: block;
		}
	}

	.tc {
		background-color: #fff;
		border-radius: 40rpx 40rpx 0 0;
		margin-top: -28rpx;
		padding: 0px $interval 30rpx;

		.head {
			height: 110rpx;
			display: flex;
			justify-content: flex-end;
			align-items: center;
			position: relative;

			.avatrar {
				position: absolute;
				top: -50rpx;
				left: 0px;
				width: 150rpx;
				height: 150rpx;
				border-radius: 50%;
				border: 1px solid #fff;
			}

			.attr {
				display: flex;
				justify-content: center;
				align-items: center;
				margin-right: $interval;

				.item {
					text-align: center;
				}

				.item:nth-child(2) {
					margin: 0px 105rpx;
				}

				.text {
					font-size: 24rpx;
					color: #a1a0a0;
				}

				.num {
					margin-top: 5rpx;
					font-weight: 600;
					font-size: $font-size-max + 4;

					text {
						font-size: -2 + $font-size;
						margin-left: -10rpx;
					}
				}
			}
		}

		.name {
			font-size: $font-size-max + 4;
			font-weight: bold;
			margin-top: $interval-min + 4;
			margin-bottom: 15rpx;
		}

		.info {
			display: flex;
			align-items: center;
			margin-top: 10rpx;
			color: #7b7b7b;

			.img {
				width: 32rpx;
				margin-right: 14rpx;
			}
		}
	}

	.tabs {
		display: flex;
		justify-content: space-between;
		background-color: #fff;
		border-radius: 0rpx 0rpx 20rpx 20rpx;
		padding: 12rpx 24rpx 10rpx;

		.item {
			font-size: 28rpx;

			.img {
				opacity: 0;
				width: 30rpx;
				display: block;
				margin: 10rpx auto 0px;
			}
		}

		.active {
			font-weight: bold;
			color: #029e9d;

			.img {
				opacity: 1;
			}
		}
	}

	.fixedTab {
		position: fixed;
		left: 0px;
		top: 0px;
		width: calc(100% - 2*$interval);
		z-index: 50;
		box-shadow: 0px 0px 10rpx #ddd;
	}

	.scroll-view {

	}

	.tit-a {
		padding: 0rpx 30rpx;
		height: 30rpx;
		font-size: 25rpx;
		color: #FFFFFF;
		line-height: 30rpx;
		text-align: center;
		border-radius: 20rpx 20rpx 0 20rpx;
	}

	.c {
		padding: 0px $interval 210rpx;
		background-color: $bg-color;

		.product-data-list {
			.item .img {
				height: 274rpx
			}

			.type-price {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-right: $interval;

				.type {
					color: #b0b2bf;
					font-size: $font-size-min;
				}
			}
		}

		.yang {
			.title {
				height: 80rpx;
				font-size: $font-size-max + 4;
			}

			.type-name {
				color: $text-color-grey;
				font-size: $font-size-min;
				padding: $interval-min;
			}
		}
	}

  .companyDetail [alt]{width: 100%;}

	.contact-close {
		padding: 48rpx;
		text-align: center;

		.img {
			width: 60rpx;
		}
	}

	.contact-module {
		width: 594rpx;
		background: linear-gradient(180deg, #e2f9f9 0%, #ffffff 100%);
		border-radius: 36rpx;
		padding-top: 70rpx;
		padding-bottom: 48rpx;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 50rpx;

			.left {
				flex: 1;
				display: flex;
				align-items: center;
				font-size: 36rpx;
				margin-left: 34rpx;

				.name {
					text-overflow: ellipsis;
					white-space: nowrap;
					overflow: hidden;
					width: 0px;
					flex: 1;
				}

				.img {
					width: 100rpx;
					height: 100rpx;
					margin-right: 24rpx;
					border-radius: 50%;
				}
			}

			.right {
				margin-left: $interval;
				width: 48rpx;
				margin-right: 46rpx;
			}
		}

		.text {
			color: $text-color-grey;
			font-size: 28rpx;
			padding: 18rpx 34rpx;
			text-align: center;
			background: linear-gradient(270deg, #ffffff 0%, #ecf8f8 100%);
			border-radius: 8rpx;
			margin: 0px 36rpx;
		}
	}

	.on {
		background: linear-gradient(90deg, #C2C6D8 0%, #E2E7EE 100%) !important;
		/*border: 0.026666rem solid #c0c1cc !important;*/
	}

	.off {
		background: linear-gradient(275deg, #54D6D2 0%, #00AAA6 100%) !important;
	}

	.video-data {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		background-color: $bg-color;

		margin: 0px -1*$interval;
		padding: 18rpx $interval-min 100rpx;

		.item {
			width: 48.5%;
			border-radius: 20rpx;
			overflow: hidden;
			position: relative;
			background-color: #fff;
			margin-bottom: 18rpx;

			.img {
				width: 100%;
			}

			.date {
				position: absolute;
				left: 0px;
				top: 0px;
				color: #fff;
				border-bottom-right-radius: 15rpx;
				font-size: $font-size-min;
				text-align: center;
				width: 100rpx;
				padding: 10rpx 0px;
				background: rgba(0, 0, 0, 0.5);
			}

			.title {
				padding: 0px $interval-min;
				margin: 15rpx 0px 20rpx;
			}

			.user-collent {
				padding: 0px $interval-min;
				display: flex;
				padding-bottom: 10rpx;
				align-items: center;
				justify-content: space-between;
				color: rgb(161, 160, 160);

				.user {
					display: flex;
					align-items: center;
					padding-bottom: 0px;
					flex: 1;
					font-size: $font-size-min;

					.avatar {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						margin-right: 15rpx;
					}

					.text {
						flex: 1;
						width: 0;
						white-space: nowrap;
						overflow: hidden; //文本超出隐藏
						text-overflow: ellipsis; //文本超出省略号替代
					}
				}

				.num {
					font-size: $font-size-min;
				}

				.collent {
					display: flex;
					align-items: center;

					.icon {}
				}
			}
		}
	}

	.fixed-oper {
		position: fixed;
		width: 100%;
		height: 108rpx;
		left: 0px;
		bottom: 0px;
		display: flex;
		z-index: 50;
		align-items: center;
		justify-content: space-between;
		background: #ffffff;
		box-shadow: 0px 0px 6rpx #ddd;

		.icons {
			padding-left: $interval;
			display: flex;

			.item {
				text-align: center;
				margin-left: $interval;

				.img {
					width: 36rpx;
					height: 32rpx;
				}

				.name {
					text-align: center;
					margin-top: 3rpx;
					font-size: $font-size-min;
				}

				&:nth-child(2) {
					margin: 0px 60rpx;
				}
			}
		}

		.btns {
			display: flex;
			padding-right: $interval;

			.btn {
				font-size: 28rpx;
				width: 196rpx;
				line-height: 76rpx;
				color: #ffffff;
				text-align: center;
				border-radius: 38rpx;
				border: 2rpx solid #ffffff;
				background: linear-gradient(90deg, #ffc614 0%, #fe8d0b 100%);
			}

			.btn:last-child {
				background: linear-gradient(275deg, #54D6D2 0%, #00AAA6 100%);
				margin-left: 12rpx;
			}

			.btn-yes:last-child {
				background: linear-gradient(90deg, #C2C6D8 0%, #E2E7EE 100%);
			}
      image {
        width: 100%;
      }
		}
	}
</style>
